package com.cskaoyan.service.indexservice;

import com.cskaoyan.bean.goods.GoodsExample;
import com.cskaoyan.bean.goods.GoodsProductExample;
import com.cskaoyan.bean.mallbean.OrderExample;
import com.cskaoyan.bean.userbean.UserExample;
import com.cskaoyan.mapper.goodsmapper.GoodsMapper;
import com.cskaoyan.mapper.goodsmapper.GoodsProductMapper;
import com.cskaoyan.mapper.mallmapper.OrderMapper;
import com.cskaoyan.mapper.usermapper.UserMapper;
import com.cskaoyan.vo.indexvo.IndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hsp
 * @date 2021/5/11 17:02
 */
@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    OrderMapper orderMapper;
    @Autowired
    GoodsProductMapper goodsProductMapper;
    @Override
    public IndexVo getIndex() {

        Long goodsTotal = goodsMapper.countByExample(new GoodsExample());
        Long userTotal = userMapper.countByExample(new UserExample());
        Long productTotal = goodsProductMapper.countByExample(new GoodsProductExample());
        Long orderTotal = orderMapper.countByExample(new OrderExample());
        IndexVo indexVo = new IndexVo(goodsTotal.intValue(),userTotal.intValue(),
                productTotal.intValue(),
                orderTotal.intValue());

        return indexVo;
    }
}
